package com.crealth.memcached;

import java.util.List;
import com.crealth.db.LendingAgencyDb;
import com.crealth.model.LendingAgencyModel;

public class LendingAgencyCached {

	private static final String Key = "all_lending_agency";	
	
	@SuppressWarnings("unchecked")
	public static List<LendingAgencyModel> selectAllLendingAgency() {
		Object obj = MemcachedMgr.cachedClient.get(Key);
		List<LendingAgencyModel> allAgencyls = null;
		if (obj == null) {
			allAgencyls = LendingAgencyDb.selectAllLendingAgency();
			if (allAgencyls != null) {
				MemcachedMgr.cachedClient.set(Key, allAgencyls);
			}
		}
		else {
			allAgencyls = (List<LendingAgencyModel>)obj;
		}
		
		return allAgencyls;
	}
	
	
	public static void deleteCached() {
		MemcachedMgr.cachedClient.delete(Key);
	}
	
	
}
